<?php
class query extends parent_class
{
	protected $params=array();
	protected $database=NULL;
	
	function __construct($database=NULL)
	{
		if (!($database instanceof mysqli_class))
		{
			$this->error(1);
		}
		if (!$database->database)
		{
			$this->error(2);
		}
		$this->database=$database;
		$this->reset();
		
	}
	
	public function addparam($value,$type)
	{
		$this->params[]=array($value,$type);
	}
	
	public function reset()
	{
		$this->params=array();
	}
	
	public function query($query)
	{
		if (!($tmp=$this->database->database->prepare($query)))
		{
			$this->error(1);
		}
		$tmp_str="";
		$tmp_str2="";
		foreach($this->params as $key => $param)
		{
			$tmp_str.=$param[1];
			if ($tmp_str2!="")
			{
				$tmp_str2.=",";
			}
			$tmp_str2.='$this->params['.$key.'][0]';
		}
		eval('$tmp->bind_param('."\"".$tmp_str."\",".$tmp_str2.");");
		$tmp->execute();
		$tmp->close();
	}
	
}
?>